*******************************
*** The following set of commmand is used to generate the stata output for the tables in our paper

clear
set more off
set matsize 3000

cd "C:\Users\stchan\Dropbox\Classes\Advanced Stats\Replication Paper\20150592_data"
		
use dece,clear
tab govdummy,gen(_Igovdum)
tab year,gen(_Iyear)
tab ind2,gen(_Iind2) 

tab govdummy fdece, m

***************************************************************************************
*Table 1 - Regression coefficients
***************************************************************************************

probit fdece lndis lnasset ROS importance Dfsoe prov_gdpper prov_SOE unemployment _Iyear* _Igovdum* _Iind2*
outreg2 using "regression_coeff.xls", dec(4)

***************************************************************************************
*Table 2 - Marginal effects holding covariates at Mean
***************************************************************************************
****SUCCESSFUL GETTING MARGINS AT MEAN
margins, dydx(lndis lnasset ROS importance Dfsoe prov_gdpper prov_SOE unemployment) atmeans

***************************************************************************************
*Table 3 - Marginal effects holding covariates at Median
***************************************************************************************
**** MARGINAL EFFECT at MEDIAN
*first, check that medians are at 0 
tabstat _Igovdum*, stat(median)
tabstat _Iyear*, stat(median)
tabstat _Iind*, stat(median)
	*YES, they are

margins, dydx(lndis lnasset ROS importance Dfsoe prov_gdpper prov_SOE unemployment) at ((median) lndis lnasset ROS importance Dfsoe prov_gdpper prov_SOE unemployment ///
		_Iyear1=0 _Iyear2=0 _Iyear3=0 _Iyear4=0 _Iyear5=0 _Iyear6=0 _Iyear7=0 _Iyear8=0 _Iyear9=0 ///
		_Igovdum1=0	_Igovdum2=0	_Igovdum3=0	_Igovdum4=0	_Igovdum5=0	_Igovdum6=0	_Igovdum7=0	_Igovdum8=0	_Igovdum9=0	_Igovdum10=0	_Igovdum11=0	_Igovdum12=0	_Igovdum13=0	_Igovdum14=0	_Igovdum15=0	_Igovdum16=0	_Igovdum17=0	_Igovdum18=0	_Igovdum19=0	_Igovdum20=0	_Igovdum21=0	_Igovdum22=0	_Igovdum23=0	_Igovdum24=0	_Igovdum25=0	_Igovdum26=0	_Igovdum27=0	_Igovdum28=0	_Igovdum29=0	_Igovdum30=0	_Igovdum31=0	_Igovdum32=0	_Igovdum33=0	_Igovdum34=0	_Igovdum35=0	_Igovdum36=0	_Igovdum37=0	_Igovdum38=0	_Igovdum39=0	_Igovdum40=0	_Igovdum41=0	_Igovdum42=0	_Igovdum43=0	_Igovdum44=0	_Igovdum45=0	_Igovdum46=0	_Igovdum47=0	_Igovdum48=0	_Igovdum49=0	_Igovdum50=0	_Igovdum51=0	_Igovdum52=0	_Igovdum53=0	_Igovdum54=0	_Igovdum55=0	_Igovdum56=0	_Igovdum57=0	_Igovdum58=0	_Igovdum59=0	_Igovdum60=0	_Igovdum61=0	_Igovdum62=0	_Igovdum63=0	_Igovdum64=0	_Igovdum65=0	_Igovdum66=0	_Igovdum67=0	_Igovdum68=0	_Igovdum69=0	_Igovdum70=0	_Igovdum71=0	_Igovdum72=0	_Igovdum73=0	_Igovdum74=0	_Igovdum75=0	_Igovdum76=0	_Igovdum77=0	_Igovdum78=0	_Igovdum79=0	_Igovdum80=0	_Igovdum81=0	_Igovdum82=0	_Igovdum83=0	_Igovdum84=0	_Igovdum85=0	_Igovdum86=0	_Igovdum87=0	_Igovdum88=0	_Igovdum89=0	_Igovdum90=0	_Igovdum91=0	_Igovdum92=0	_Igovdum93=0	_Igovdum94=0	_Igovdum95=0	_Igovdum96=0	_Igovdum97=0	_Igovdum98=0	_Igovdum99=0	_Igovdum100=0	///
		_Igovdum101=0	_Igovdum102=0	_Igovdum103=0	_Igovdum104=0	_Igovdum105=0	_Igovdum106=0	_Igovdum107=0	_Igovdum108=0	_Igovdum109=0	_Igovdum110=0	_Igovdum111=0	_Igovdum112=0	_Igovdum113=0	_Igovdum114=0	_Igovdum115=0	_Igovdum116=0	_Igovdum117=0	_Igovdum118=0	_Igovdum119=0	_Igovdum120=0	_Igovdum121=0	_Igovdum122=0	_Igovdum123=0	_Igovdum124=0	_Igovdum125=0	_Igovdum126=0	_Igovdum127=0	_Igovdum128=0	_Igovdum129=0	_Igovdum130=0	_Igovdum131=0	_Igovdum132=0	_Igovdum133=0	_Igovdum134=0	_Igovdum135=0	_Igovdum136=0	_Igovdum137=0	_Igovdum138=0	_Igovdum139=0	_Igovdum140=0	_Igovdum141=0	_Igovdum142=0	_Igovdum143=0	_Igovdum144=0	_Igovdum145=0	_Igovdum146=0	_Igovdum147=0	_Igovdum148=0	_Igovdum149=0	_Igovdum150=0	_Igovdum151=0	_Igovdum152=0	_Igovdum153=0	_Igovdum154=0	_Igovdum155=0	_Igovdum156=0	_Igovdum157=0	_Igovdum158=0	_Igovdum159=0	_Igovdum160=0	_Igovdum161=0	_Igovdum162=0	_Igovdum163=0	_Igovdum164=0	_Igovdum165=0	_Igovdum166=0	_Igovdum167=0	_Igovdum168=0	_Igovdum169=0	_Igovdum170=0	_Igovdum171=0	_Igovdum172=0	_Igovdum173=0	_Igovdum174=0	_Igovdum175=0	_Igovdum176=0	_Igovdum177=0	_Igovdum178=0	_Igovdum179=0	_Igovdum180=0	_Igovdum181=0	_Igovdum182=0	_Igovdum183=0	_Igovdum184=0	_Igovdum185=0	_Igovdum186=0	_Igovdum187=0	_Igovdum188=0	_Igovdum189=0	_Igovdum190=0	_Igovdum191=0	_Igovdum192=0	_Igovdum193=0	_Igovdum194=0	_Igovdum195=0	_Igovdum196=0	_Igovdum197=0	_Igovdum198=0	_Igovdum199=0	_Igovdum200=0	/// 
		_Igovdum201=0	_Igovdum202=0	_Igovdum203=0	_Igovdum204=0	_Igovdum205=0	_Igovdum206=0	_Igovdum207=0	_Igovdum208=0	_Igovdum209=0	_Igovdum210=0	_Igovdum211=0	_Igovdum212=0	_Igovdum213=0	_Igovdum214=0	_Igovdum215=0	_Igovdum216=0	_Igovdum217=0	_Igovdum218=0	_Igovdum219=0	_Igovdum220=0	_Igovdum221=0	_Igovdum222=0	_Igovdum223=0	_Igovdum224=0	_Igovdum225=0	_Igovdum226=0	_Igovdum227=0	_Igovdum228=0	_Igovdum229=0	_Igovdum230=0	_Igovdum231=0	_Igovdum232=0	_Igovdum233=0	_Igovdum234=0	_Igovdum235=0	_Igovdum236=0	_Igovdum237=0	_Igovdum238=0	_Igovdum239=0	_Igovdum240=0	_Igovdum241=0	_Igovdum242=0	_Igovdum243=0	_Igovdum244=0	_Igovdum245=0	_Igovdum246=0	_Igovdum247=0	_Igovdum248=0	_Igovdum249=0	_Igovdum250=0	_Igovdum251=0	_Igovdum252=0	_Igovdum253=0	_Igovdum254=0	_Igovdum255=0	_Igovdum256=0	_Igovdum257=0	_Igovdum258=0	_Igovdum259=0	_Igovdum260=0	_Igovdum261=0	_Igovdum262=0	_Igovdum263=0	_Igovdum264=0	_Igovdum265=0	_Igovdum266=0	_Igovdum267=0	_Igovdum268=0	_Igovdum269=0	_Igovdum270=0	_Igovdum271=0	_Igovdum272=0	_Igovdum273=0	_Igovdum274=0	_Igovdum275=0	_Igovdum276=0	_Igovdum277=0	_Igovdum278=0	_Igovdum279=0	_Igovdum280=0	_Igovdum281=0	_Igovdum282=0	_Igovdum283=0	_Igovdum284=0	_Igovdum285=0	_Igovdum286=0	_Igovdum287=0	_Igovdum288=0	_Igovdum289=0	_Igovdum290=0	_Igovdum291=0	_Igovdum292=0	_Igovdum293=0	_Igovdum294=0	_Igovdum295=0	_Igovdum296=0	_Igovdum297=0	_Igovdum298=0	_Igovdum299=0	_Igovdum300=0	///
		_Igovdum301=0	_Igovdum302=0	_Igovdum303=0	_Igovdum304=0	_Igovdum305=0	_Igovdum306=0	_Igovdum307=0	_Igovdum308=0	_Igovdum309=0	_Igovdum310=0	_Igovdum311=0	_Igovdum312=0	_Igovdum313=0	_Igovdum314=0	_Igovdum315=0	_Igovdum316=0	_Igovdum317=0	_Igovdum318=0	_Igovdum319=0	_Igovdum320=0	_Igovdum321=0	_Igovdum322=0	_Igovdum323=0	_Igovdum324=0	_Igovdum325=0	_Igovdum326=0	_Igovdum327=0	_Igovdum328=0	_Igovdum329=0	_Igovdum330=0	_Igovdum331=0	_Igovdum332=0	_Igovdum333=0	_Igovdum334=0	_Igovdum335=0	_Igovdum336=0	_Igovdum337=0	_Igovdum338=0	_Igovdum339=0	_Igovdum340=0	_Igovdum341=0	_Igovdum342=0	_Igovdum343=0	_Igovdum344=0	_Igovdum345=0	_Igovdum346=0	_Igovdum347=0	_Igovdum348=0	_Igovdum349=0 ///
		_Iind21=0	_Iind22=0	_Iind23=0	_Iind24=0	_Iind25=0	_Iind26=0	_Iind27=0	_Iind28=0	_Iind29=0 ///
		_Iind210=0	_Iind211=0	_Iind212=0	_Iind213=0	_Iind214=0	_Iind215=0	_Iind216=0	_Iind217=0	_Iind218=0	_Iind219=0	_Iind220=0	_Iind221=0	_Iind222=0	_Iind223=0	_Iind224=0	_Iind225=0	_Iind226=0	_Iind227=0	_Iind228=0	_Iind229=0	_Iind230=0	_Iind231=0	_Iind232=0	_Iind233=0	_Iind234=0	_Iind235=0	_Iind236=0	_Iind237=0	_Iind238=0)

***************************************************************************************
*Table 4 - Average Marginal effects 
***************************************************************************************		
**** AVERAGE MARGINAL EFFECT 
margins, dydx(lndis lnasset ROS importance Dfsoe prov_gdpper prov_SOE unemployment) 

*side: you can also run dprobit (old command but used in original paper) to get the same results 
dprobit fdece lndis lnasset ROS importance Dfsoe prov_gdpper prov_SOE unemployment _Iyear* _Igovdum* _Iind2*

